/*
 * Copyright (C) 拾光分享网 
 * All rights reserved, Designed By www.hiai.top.
 * Email：goodsking@163.com.
 * Version：V1.0.2(20230701).
 */
package top.hiai.common.model;

import top.hiai.common.model.base.FavoriteBase;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author www.hiai.top
 * @Email goodsking@163.com
 * @Message 更多资源尽在www.hiai.top
 * @Introduction 类的介绍
 */

@SuppressWarnings("serial")
public class Favorite extends FavoriteBase<Favorite> {

    /**
     * 收藏引用的文章类型
     */
    public static final int REF_TYPE_ARTICLE = 1;
    /**
     * 收藏引用的话题类型
     */
    public static final int REF_TYPE_COMMENTS = 2;

    private static Map<String, Integer> tableToTypeValue = new HashMap<String, Integer>() {{
        put("article", REF_TYPE_ARTICLE);
        put("comments", REF_TYPE_COMMENTS);
    }};

    public static int getRefType(String tableName) {
        Integer refType = tableToTypeValue.get(tableName);
        if (refType == null) {
            throw new IllegalArgumentException("tableName 不正确");
        }
        return refType;
    }

    public static void checkRefTypeTable(String refTypeTable) {
        if (!tableToTypeValue.containsKey(refTypeTable)) {
            throw new IllegalArgumentException("refType 不正确");
        }
    }
}